package chapter5;
import java.util.Scanner;
/****************************************************************
 * Author：icynlau
 * Description: 石头剪刀布直到用户或计算机赢对方两次
 * 		0-Scissors 1-Rock 2-Paper
 * Date:2021/4/4
 * ***************************************************************
 */
public class exc5_34 {
	public static void main(String[] args) {
		int winTime1=0,winTime2=0;//计算双方胜场数
		String[] array= {"Scissors","Rock","Paper"};
		Scanner input=new Scanner(System.in);
		
		
		do {
			System.out.print("Enter the number (0-Scissors 1-Rock 2-Paper):  ");
			int pe=input.nextInt();
			int pc=(int)(Math.random()*3);
			if(pc-pe==-1||pc-pe==2) {
				//pe赢
				System.out.printf("pc-%s  and you-%s   You win!\n", array[pc],array[pe]);
				winTime2++;
			}else if(pc-pe==-2||pc-pe==1) {
				//pc赢
				System.out.printf("pc-%s  and you-%s   You lose.\n", array[pc],array[pe]);
				winTime1++;
			}else {
				//平局
				System.out.printf("pc-%s  and you-%s   Draw.\n", array[pc],array[pe]);
			}
			
		}while(winTime1!=2&&winTime2!=2);
		
		if(winTime1==2) {
			System.out.print("Sorry ,PC is the winner.");
		}else {
			System.out.print("You are the winner!");
		}
		
	}

}
